package edu.umich.PowerTutor.phone;

import edu.umich.PowerTutor.components.CPU.CpuData;
import edu.umich.PowerTutor.components.LCD.LcdData;
import edu.umich.PowerTutor.components.OLED.OledData;
import edu.umich.PowerTutor.components.Wifi.WifiData;
import android.content.Context;

public class M110sPowerCalculator extends DreamPowerCalculator{

	public M110sPowerCalculator(Context context) {
		super(new BravoConstants(context));
	}

	public M110sPowerCalculator(PhoneConstants coeffs) {
		super(coeffs);
	}

	@Override
	public double getOledPower(OledData data) {
		if (!data.screenOn) {
			return 0;
		}
		if (data.pixPower == -1) {
			/* No pixel power available :(. */
			return coeffs.oledBasePower() + coeffs.lcdBrightness()
					* data.brightness;
		} else {
			// 원래 이곳을 통해서 픽셀 파워가 결정 되어야 한다. 하지만 난 bright로만 power 소비를 결정 한다.
			return coeffs.oledBasePower() + coeffs.lcdBrightness()
					* data.brightness;
			// return coeffs.oledBasePower() + data.pixPower * data.brightness;
		}
	}

	// Galaxy S LCD Power Model
	@Override
	public double getLcdPower(LcdData data) {
		/*
		 * return data.screenOn ? coeffs.lcdBrightness() * data.brightness +
		 * coeffs.lcdBacklight() : 0;
		 */
		return data.screenOn ? coeffs.lcdBrightness() * data.brightness
				+ coeffs.lcdBacklight() : 0;
	}

	// Galaxy S wifi power model 이다.
	@Override
	public double getWifiPower(WifiData data) {
		if (!data.wifiOn) {
			return 0;
		} else {
			double wifiPower = Math.max(0,578.849+
	    			data.packets*0.727+
	    			Math.pow(data.packets,2)*0.001);
			if (data.packets >= 1200) {
				return 1451;
			} else {
				return wifiPower;
			}
		}
	}
	// Galaxy S cpu power model 이다.
	@Override
	public double getCpuPower(CpuData data) {
		// HTC Desire cpu power model 이다.
		return Math.max(0, 9.934 * (data.usrPerc + data.sysPerc) + 253.173);
	}
}
